package com.tjx.controller;


import com.tjx.common.Result;
import com.tjx.entity.Carousel;
import com.tjx.mapper.CarouselMapper;
import com.tjx.service.ICarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图表 前端控制器
 * </p>
 *
 * @author tjx
 * @since 2025-10-29
 */
@RestController
@RequestMapping("/carousel")
public class CarouselController {
    @Autowired
    private ICarouselService carouselService;

    /**
     * 查询所有轮播图
     */
    @RequestMapping("/carouselQueryAll")
    public Result<List<Carousel>> carouselQueryAll() {
        List<Carousel> carouselList = carouselService.carouselQueryAll();
        if (carouselList != null) {
            return Result.ok(carouselList);
        }
        return Result.fail();
    }

    /**
     * 修改轮播图
     */
    @RequestMapping("/carouselUpdate")
    public Result<Carousel> carouselUpdate(@RequestBody Carousel carousel) {
        Integer row = carouselService.carouselUpdate(carousel);
        if (row > 0) {
            return Result.ok();
        }
        return Result.fail();
    }
}
